#ifndef _CAMERA_HPP
#define _CAMERA_HPP

#include "SceneNode.hpp"
#include "Maths.hpp"

class Camera
{
	// TODO: Work out how to store a node-specific margin
	SceneNodeCollection m_target_nodes;
	
	// Space between outer edge of target and edge of screen
	Scalar m_padding;

	AABB m_aabb;
	
public:
	
	//void moveBy(const Vector& val);
	//void moveTo(const Vector& val);
	//void moveDirectTo(const Vector& val);
	
	void setTarget(const SceneNode* node)
	{ m_targets.clear(); m_targets.push_back(node); }
	void addTarget(const SceneNode* node)
	{ m_targets.push_back(node); }
	void removeTarget(const SceneNode* node)
	{ m_targets.remove(node); }
	void clearTargets() { m_targets.clear(); }
	
	void findVisibleSubNodes(const SceneNode* node,
							 SceneNodeCollection& output_list)
		{
			// TODO: Include node-specific margins in this calculation
			if( m_aabb.intersects(node->getAABB()) ) {
				if( node->isLeaf() || m_aabb.encloses(node->getAABB()) ) {
					output_list.push_back(node);
				}
				else { // Check children for visiblity
					SceneNodeCollection::const_iterator it;
					for( it=node.getChildren().begin();
						 it!=node.getChildren().end(); ++it ) {
						findVisibleSubNodes(*it, output_list);
					}
				}
			}
		}

	void update()
		{
			// TODO: Implement this. Constraints: fixed aspect ratio, min bounding rect (i.e., max zoom), minimise movement.
		}
};

#endif //_CAMERA_HPP
